import time
from selenium import webdriver
from selenium.webdriver.common.by import By
dr = webdriver.Chrome()
dr.get("https://www.ptpress.com.cn/")
time.sleep(2)
dr.maximize_window()
time.sleep(2)
# 操作滚动条
js = "window.scrollTo(0,3500)"
dr.execute_script(js)
time.sleep(2)
e = dr.find_element(By.XPATH,"/html/body/div[8]/div/div[3]/a[1]/div[1]/img")
# 保存文件
with open("book.png","wb+") as f:
    f.write(e.screenshot_as_png)
# 找到所以书的图片
e_imgs = dr.find_elements(By.CSS_SELECTOR,"#newBook .hidden-xs img")
e_names = dr.find_elements(By.CSS_SELECTOR,"#newBook .hidden-xs .title")
for i in range(len(e_names)):
    with open("新书/"+e_names[i].text+".png","wb+") as f:
        f.write(e_imgs[i].screenshot_as_png)
dr.quit()